package bavaria.hightech.banking;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import bavaria.hightech.formatter.Formatter;

public class Statement {
	

	private Map <String,Formatter> formatters = new HashMap<String,Formatter>();
	
	public Statement(){
		Properties props = new Properties();
		Properties formatprops = new Properties();
		try {
			props.load(new FileInputStream("system.properties"));
			formatprops.load(new FileInputStream(props.getProperty("formatter")));
			formatters.put("text/plain", (Formatter) Class.forName(formatprops.getProperty("text/plain")).newInstance());
			formatters.put("text/html", (Formatter) Class.forName(formatprops.getProperty("text/html")).newInstance());
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	
	public Formatter getFormatter(String mimeType){
		return formatters.get(mimeType);
	}
	


}
